package com.atbeijing.bigdata.spark.mytest.core

import org.apache.spark.{SparkConf, SparkContext}


object Operator2 {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("groupBy")
    val sc = new SparkContext(conf)

    sc.textFile("input/word.txt").flatMap(w =>w.split(" ")).map(w => (w,1)).collect()
    sc.textFile("input/word.txt").flatMap(w =>w.split(" ")).map(w => (w,1)).reduceByKey(_ + _).collect()

    sc.makeRDD(List(1,2,3,4,5,6),3).map(w => (w,1)).reduceByKey(_ + _,2).collect()
  }
}
